g_clear_object (&self->uncompressed_objects_dir);
if (self->uncompressed_objects_dir_fd != -1)
(void) close (self->uncompressed_objects_dir_fd);
- g_clear_object (&self->config_file);
g_clear_object (&self->sysroot_dir);
g_free (self->remotes_config_dir);
self->deltas_dir = g_file_get_child (self->repodir, "deltas");
self->uncompressed_objects_dir = g_file_get_child (self->repodir, "uncompressed-objects-cache");
- self->config_file = g_file_get_child (self->repodir, "config");
/* Ensure the "sysroot-path" property is set. */
if (self->sysroot_dir == NULL)
g_return_val_if_fail (self->inited, FALSE);
data = g_key_file_to_data (new_config, &len, error);
- if (!g_file_replace_contents (self->config_file, data, len, NULL, FALSE, 0, NULL,
- NULL, error))
+ if (!glnx_file_replace_contents_at (self->repo_dir_fd, "config",
+ (guint8*)data, len, 0,
+ NULL, error))
goto out;
g_key_file_free (self->config);
}
else if (remote != NULL)
{
- GFile *file;
-
- if (remote->file != NULL)
- file = remote->file;
- else
- file = self->config_file;
-
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Remote configuration for \"%s\" already exists: %s",
- name, gs_file_get_path_cached (file));
-
+ name, remote->file ? gs_file_get_path_cached (remote->file) : "(in config)");
goto out;
}
}
self->config = g_key_file_new ();
- if (!g_key_file_load_from_file (self->config, gs_file_get_path_cached (self->config_file), 0, error))
- {
- g_prefix_error (error, "Couldn't parse config file: ");
+
+ { g_autofree char *contents = NULL;
+ gsize len;
+
+ contents = glnx_file_get_contents_utf8_at (self->repo_dir_fd, "config", &len,
+ NULL, error);
+ if (!contents)
goto out;
- }
+ if (!g_key_file_load_from_data (self->config, contents, len, 0, error))
+ {
+ g_prefix_error (error, "Couldn't parse config file: ");
+ goto out;
+ }
+ }
if (!add_remotes_from_keyfile (self, self->config, NULL, error))
goto out;